package pl.edu.uw.come.mooba.domain;

import java.net.URL;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;


/**
 *
 * @author Piotr Kochański
 */
public class BackupInfo {
    private String archFileName;
    private String backupVersion;
    private Calendar backupDate;
    private URL originalWWWroot;

    private String moodleVersion;
    private String moodleRelease;
    private String backupRelease;

    public static String ARCHIVE_FILE_NAME_TAG = "NAME";
    public static String MOODLE_VERSION_TAG = "MOODLE_VERSION";
    public static String MOODLE_RELEASE_TAG = "MOODLE_RELEASE";
    public static String BACKUP_VERSION_TAG = "BACKUP_VERSION";
    public static String BACKUP_RELEASE_TAG = "BACKUP_RELEASE";
    public static String BACKUP_DATE_TAG = "DATE";
    public static String ORIGINAL_WWWROOT_TAG = "ORIGINAL_WWWROOT";


    public static String BASE_XPATH = "//MOODLE_BACKUP/INFO/";

    public String getArchFileName() {
        return archFileName;
    }

    public void setArchFileName(String archFileName) {
        this.archFileName = archFileName;
    }

    public Calendar getBackupDate() {
        Calendar c = new GregorianCalendar();
        c.setTimeInMillis(backupDate.getTimeInMillis());
        return c;
    }

    public void setBackupDate(Calendar backupDate) {
        this.backupDate = backupDate;
    }

    public String getBackupRelease() {
        return backupRelease;
    }

    public void setBackupRelease(String backupRelease) {
        this.backupRelease = backupRelease;
    }

    public String getBackupVersion() {
        return backupVersion;
    }

    public void setBackupVersion(String backupVersion) {
        this.backupVersion = backupVersion;
    }

    public String getMoodleRelease() {
        return moodleRelease;
    }

    public void setMoodleRelease(String moodleRelease) {
        this.moodleRelease = moodleRelease;
    }

    public String getMoodleVersion() {
        return moodleVersion;
    }

    public void setMoodleVersion(String moodleVersion) {
        this.moodleVersion = moodleVersion;
    }

    public URL getOriginalWWWroot() {
        return originalWWWroot;
    }

    public void setOriginalWWWroot(URL originalWWWroot) {
        this.originalWWWroot = originalWWWroot;
    }

    @Override
    public String toString() {
        DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
        return "course archived in "  + archFileName + " from " + originalWWWroot + " backuped on " + df.format(backupDate.getTime());
    }



}

/*

<MOODLE_BACKUP>
  <INFO>
    <NAME>backup-ja_0_szkolenie_5-20100125-1119.zip</NAME>
    <MOODLE_VERSION>2007101530</MOODLE_VERSION>
    <MOODLE_RELEASE>1.9.3+ (Build: 20081022)</MOODLE_RELEASE>
    <BACKUP_VERSION>2008030300</BACKUP_VERSION>
    <BACKUP_RELEASE>1.9</BACKUP_RELEASE>
    <DATE>1264414755</DATE>
    <ORIGINAL_WWWROOT>http://jezyki.come.uw.edu.pl</ORIGINAL_WWWROOT>


 */